package com.szpx.mapper;

import com.szpx.entity.CartItem;
import org.apache.ibatis.annotations.*;

@Mapper
public interface CartMapper {

    @Select("SELECT * FROM tb_cart WHERE uid = #{userId} AND gid = #{productId}")
    CartItem findCartItem(@Param("userId") int userId, @Param("productId") int productId);

    @Insert("INSERT INTO tb_cart (uid, gid, cnt, opttime) VALUES (#{userId}, #{productId}, #{quantity}, #{createTime})")
    int insertCartItem(CartItem cartItem);

    @Update("UPDATE tb_cart SET cnt = #{quantity} WHERE cid = #{cid}")
    int updateCartItem(CartItem cartItem);

}
